<script setup lang="ts">
import {computed} from "vue";
import ChartLhz from '../../components/ChartLhz.vue'

const props = defineProps(["chart_option"])
const { chart_option } = props
const options = computed(() => {
  let option = {
    title: {
      text: '某地区空气质量',
      textStyle: {
        color: 'orange', // 标题颜色
        fontSize: 18, // 字号大小
        fontWeight: 'bold' // 字体加粗
      }
    },
    tooltip: {
      trigger: 'axis'
    },
    legend: {
      data: []
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true
    },
    toolbox: {
      feature: {
        saveAsImage: {}
      }
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data: [],
      axisLabel: {
        color: '#fff'
      }
    },
    yAxis: {
      type: 'value',
      axisLabel: {
        color: '#fff'
      }
    },
    series: [

      {
        name: '',
        type: 'line',
        stack: 'Total',
        data: [92,103,156,91,89]
      },
      {
        name: '',
        type: 'line',
        stack: 'Total',
        data: [114,209,178,144,120]
      },
      {
        name: '',
        type: 'line',
        stack: 'Total',
        data: [56,89,103,186,256]
      },
      {
        name: '',
        type: 'line',
        stack: 'Total',
        data: [67,56,46,113,126]
      },
    ]
  };
  option.xAxis.data=chart_option[0]
  // console.log(chart_option)
  const names:Array<string> = ["Moderate","Good","Hazardous","Poor"]
  option.legend.data=[]
  for(const name of names){
    option.legend.data.push(name)
  }

  option.series[0].name=chart_option[6][0]
  option.series[1].name=chart_option[6][1]
  option.series[2].name=chart_option[6][2]
  option.series[3].name=chart_option[6][3]


  // option.series[0].data=chart_option[1]
  // option.series[1].data=chart_option[2]
  // option.series[2].data=chart_option[3]
  // option.series[3].data=chart_option[4]
  // option.series=[]

  // let name1=[]
  //   for(let n=0;n<4;n++){
  //     for(let m=0;m<5;m++)
  //     {
  //     name1[m][n]=names[m][n]
  //     }
  //   }
  //   console.log(name1)


  // for(let i=1;i<5;i++){
  //   let arr=[]
  //
  //     // for(let m=0;m<7;m++){
  //     //   for(let n=0;n<4;n++) {
  //     //     arr = chart_option[m][n]
  //     //     console.log(arr)
  //     //   }
  //     // }
  //
  //   option.series.push(
  //       {
  //         name: names.shift(),
  //         type: 'line',
  //         stack: 'Total',
  //         data: chart_option[i]
  //       }
  //   )
  // }
  //92 114 56 67
  //103 209 89 56
  //156 178 103 46
  //91 144 186 113
  //89 102 256 126


  return option
})
</script>

<template>
  <chart-lhz :chart_option="options" v-if="chart_option"></chart-lhz>
</template>


<style scoped>
</style>